package com.sms.dao.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.sms.dao.INumconfigDAO;
import com.sms.po.TNumconfig;
/**
 * @author 20120102 by cxh
 */
public class NumconfigDAO extends HibernateDaoSupport implements INumconfigDAO {
	private static final Log log = LogFactory.getLog(NumconfigDAO.class);

	@SuppressWarnings("unchecked")
	@Override
	public List<TNumconfig> showAllTNumconfig() {
		log.debug("finding all Numconfig instances");
		try{
			return super.getHibernateTemplate().find("from TNumconfig");
		}catch(RuntimeException e){
			log.debug("finding all failed:",e);
			throw e;
		}
	}
	
	public boolean isNumExist(String phone) {
		log.debug("finding Numconfig instances");
		try{
			List<TNumconfig> numList = getHibernateTemplate().find("from TNumconfig where startNum <" + phone + " and endNum > " + phone);
			return !numList.isEmpty();
		}catch(RuntimeException e){
			log.debug("finding all failed:",e);
			throw e;
		}
	}

}
